package eightDataType;

/**
 * @author Ajie
 * @date 8/20/21
 * @function   TODO 注意包装类型拆装箱引起的空指针问题
 */
public class IntegerDemo {

    public static int getInt(String key, int def) {
        try {
//            String value = this.get(key);
//            String value = null;//def ok
            String value = ""; //def ok
            return Integer.parseInt(value);
        } catch (NumberFormatException var4) {
            System.out.println("getInt " + key + " happened exception");
            return def;
        }
    }


    public static void main(String[] args) {

        System.out.println("IntegerDemo:main:>>>>"+getInt("abc",8));




        System.out.println("IntegerDemo:main:  (-2%10):"+(-2%10));//-2
        Integer intWaper = null;
        System.out.println("IntegerDemo:main:"+(intWaper ==1));

        int a = 100;
        Integer b =200;
        Long c = 300L;
        System.out.println(""+c.equals(a+b));//false 数据类型不同。
        //  Long
        //  public boolean equals(Object obj) {
        //        if (obj instanceof Long) {
        //            return value == ((Long)obj).longValue();
        //        }
        //        return false;
        //    }

//        System.out.println(((a+b) instanceof Long));//java: 编译不过 意外的类型 需要: 引用 找到:    int


        Integer b5 = 500;
        Integer b55 = 500;
        System.out.println(" == "+(b5==b55));//false
        System.out.println(" == "+(b5==500));//true //当== 一方是基本数据类型时，另一方自动拆箱
        Integer b3 = 300;
        Integer b2 = 200;
        System.out.println(" == "+(b5==(b2+b3)));//true // +-*/自动拆箱
    }

    public static void test(long l){}
}
